<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link href="/res/third/bootstrap3/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
<script src="/res/common/js/jquery.1.9.1.min.js" type="text/javascript"></script>
<script src="/res/third/easyUI/jquery.easyui.min.js" type="text/javascript"></script>
<script src="/res/third/artDialog/jquery.artDialog.js" type="text/javascript"></script>
<script type="text/javascript">

//搜索
function sosuo(){
	var lpath = location.pathname;
	var pageNo = $("#pageNo").val();
	$("#souroleform").attr("action", lpath + "?pageNo=" + pageNo);
	$("#souroleform").submit();
}
//新增角色
function addRole(){
	dialog = art.dialog.load("新增角色","/user_permission/v_roledialog.do",{
	});
}
//编辑角色
function editRole(roleId){
	dialog = art.dialog.load("编辑角色","/user_permission/v_roledialog.do",{
		roleId:roleId
	});
}
//删除角色
function delRole(roleId){
	 if(confirm("是否确认删除此角色？")){
		 $.ajax({
			   type: "post",
			   dataType:"json",
			   url: "/user_permission/o_delrole.do",
			   data:{roleId:roleId},
			   success: function(data){//成功的时候调用
				   if(data.success){
					   art.dialog.alert(data.msg,function(){
					   		location.reload();
					   })
				   }else{
					   art.dialog.tips(data.msg);
				   }
			   }
		});
	 }
}
</script>
</head>
<body>
	<div class="panel panel-info panel-content">
		<div class="panel-heading">
			<form id="souroleform" method="post" action="">
				<button type="button" class="btn btn-info" onclick="addRole()">添加角色</button>
				 
				<div class="input-group" style="width: 200px; float: right;">
				 	<input type="text" class="form-control" name="so_urole"
						value='${uroleName!}' placeholder="角色名称搜索" /><span
						class="input-group-btn"> 
						<button class="btn btn-default" type="button" onclick="sosuo()">搜索</button>
					</span>
				</div>
			</form>
		</div>
			<table class="table table-bordered table-hover table-striped">
				<thead>
					<tr>
						<th  width="5%">序号</th>
						<th  style="text-align: center" width="30%">角色名称</th>
						<th  style="text-align: center" width="10%">编号</th>
						<th  style="text-align: center" width="10%">角色类别</th>
						<th  style="text-align: center" width="10%">排序</th>
						<th  style="text-align: center" width="20%">操作</th>
					</tr>
				</thead>
				<tbody>
				[#list pagination.list as urole]
				    <tr>
				    <td style="text-align: center">${pagination.pageSize * (pagination.pageNo-1)+urole_index+1}</td>
				    <td style="text-align: center">${urole.name!}</td>
				    <td style="text-align: center">${urole.code!}</td>
				    <td style="text-align: center">[#if urole.roleType==1]采购商[/#if][#if urole.roleType==2]供应商[/#if][#if urole.roleType==3]注册用户[/#if]</td>
				    <td style="text-align: center">${urole.sortNum!}</td>
				    <td style="text-align: center">
					<button type="button" class="btn btn-info btn-xs edits" onclick="editRole(${urole.id})">编辑角色</button>
					<button type="button" class="btn btn-danger btn-xs delbtn" onclick="delRole(${urole.id})">删除</button>
				    </td>
				    </tr>
				[/#list]
				</tbody> 
			</table>
				<div class="panel-footer">[@fenye p = pagination form = 'infoForm' /]</div>
	</div>
</body>
</html>